#e
#Title[tu|bJɋt -Lunatic-v]
#Text[]
#ScriptVersion[2]

script_enemy_main {
	let name	= "tu|bJɋtāv";
	let imgHimari=GetCurrentScriptDirectory~"img\dot_Himari.png";
    	let csd         = GetCurrentScriptDirectory;
    	let shotImage   = csd ~ "data_usershot.txt";
	let wavA	= csd ~ "SE\shot1.wav";
	let wavB	= csd ~ "SE\shot2.wav";
	let pororocca	= 149;
	let juu		= 94;
	let base	= 320;

	let wIni = 120;
	
	///////////////////////////////////////////////////////////

	@Initialize{
        CutIn(YOUMU, name, "", 0, 0, 0, 0);
	LoadGraphic(imgHimari);

        SetMovePosition02(GetCenterX(), GetClipMinY+60, 60);
        SetLife(5000);
        SetTimer(91);
	SetScore(800000);
        SetDamageRate(100, 20);
	SetInvincibility( 260 );
        LoadUserShotData(shotImage);
	SetDurableSpellCard;

	TMain();
	TMain2();
	TSub();
	TWav();

	}
		
	@MainLoop{
	    SetCollisionA(GetX, GetY, 32);
	    SetCollisionB(GetX, GetY, 16);

	    yield;
	}
	
	@DrawLoop{
	    SetTexture(imgHimari);
	    DrawGraphic(GetX(), GetY());
	    if(GetSpeedX()>0){SetGraphicRect(192,1,255,64);}
	    else if(GetSpeedX()<0){SetGraphicRect(128,1,191,64);}
	}
		
	@Finalize{
	    DeleteGraphic(imgHimari);
	}

	task TMain{

	    yield;
	    loop(120){ yield; }

	loop{
	loop(100){
	poro;
	poro;
	base--;
	loop(3){ yield; }
	}
	loop(100){
	poro;
	poro;
	base++;
	loop(3){ yield; }
	}
	}

	}

	task TMain2{
	SetGraphicRect(1,1,64,64);

	    yield;
	    loop(120){ yield; }

	loop{
	SetGraphicRect(1,1,64,64);
	loop(320){ yield; }
	SetGraphicRect(64,1,128,64);
	loop(60){ yield; }
        SetMovePosition02(GetPlayerX, GetPlayerY, 60);
	loop(10){
	PlaySE(wavB);
	Shot;
	loop(6){ yield; }
	}
	loop(60){ yield; }
        SetMovePosition02(GetX(), GetClipMinY+60, 60);
	loop(60){ yield; }
	}
	}


	task TSub{

	yield;
	loop(120){ yield; }

	loop{
	SetPlayerY(GetPlayerY()+((GetClipMinY()-GetPlayerY())/220));
	yield;
	}
	}

	task TWav{

	yield;
	loop(120){ yield; }

	loop{
	PlaySE(wavA);
	loop(10){ yield; }
	}
	}

	//////////////////////////////////////////////////////////

	sub poro{
	CreateShot01(rand(GetClipMinX,GetClipMaxX),GetClipMaxY+12,rand(1.5,2.5),base,pororocca,20);
	}

	sub Shot{
	let Base	= rand(0,360);
	ascent(let i in 0..7){
	CreateShot01(GetX,GetY,2.5,Base+i*360/7,juu,20);
	}
	}
	

    // w t[҂
    function wait(w) {
        loop(w) { yield; }
    }
}